package observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Koizumi Sinya
 * @date 2018/03/19. 21:32
 * @edithor
 * @date
 */
public class AbstractSubject {
    private List<Observer> list = new ArrayList<>();

    public void attach(Observer observer) {
        list.add(observer);
    }

    public void detach(Observer observer) {
        list.remove(observer);
    }

    public void notifyObserver(String content) {
        for (Observer observer : list) {
            observer.update(content);
        }
    }
}
